package com.htudata.messager.controller;

import com.htudata.common.enums.RequestSeqEnum;
import com.htudata.common.enums.RequestStatusEnum;
import com.htudata.convention.domain.ResponseResult;
import com.htudata.core.util.ResultGenerator;
import com.htudata.messager.service.IMessagerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
public class MessagerController {

  @Autowired
  private IMessagerService messagerService;
  
  @GetMapping({"/v1/messager/getServChannelData"})
  public ResponseResult getServChannelData(@RequestParam(defaultValue = "weibo") String servChannel) {
    try {
      return ResultGenerator.genResult(RequestSeqEnum.SEQ_017.getCode(), this.messagerService
          .selectServChannelData(servChannel));
    } catch (Exception e) {
      log.error("getServChannelData",e);
      return ResultGenerator.genErrorResult(RequestSeqEnum.SEQ_017.getCode(), RequestStatusEnum.STATUS_503
          .getCode(), "暂无数据");
    } 
  }
  
  @GetMapping({"/v1/messager/getMeteoPublicUserComment"})
  public ResponseResult getMeteoPublicUserComment() {
    try {
      return ResultGenerator.genResult(RequestSeqEnum.SEQ_018.getCode(), this.messagerService
          .selectMeteoPublicUserComment());
    } catch (Exception e) {
      log.error("getMeteoPublicUserComment",e);
      return ResultGenerator.genErrorResult(RequestSeqEnum.SEQ_018.getCode(), RequestStatusEnum.STATUS_503
          .getCode(), "暂无数据");
    } 
  }
}
